package top.mcwebsite.playandroid.lib.markdown.render

import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
import org.intellij.markdown.MarkdownElementTypes
import org.intellij.markdown.MarkdownTokenTypes
import org.intellij.markdown.ast.ASTNode
import org.intellij.markdown.flavours.gfm.GFMElementTypes

@Composable
fun RenderMap(
    markdownState: MarkdownState,
    astNode: ASTNode,
) {
    Column {
        when (astNode.type) {
            MarkdownElementTypes.ATX_1,
            MarkdownElementTypes.ATX_2,
            MarkdownElementTypes.ATX_3,
            MarkdownElementTypes.ATX_4,
            MarkdownElementTypes.ATX_5,
            MarkdownElementTypes.ATX_6,
            MarkdownElementTypes.SETEXT_1,
            MarkdownElementTypes.SETEXT_2 -> {
                Heading(markdownState, astNode)
            }
            MarkdownElementTypes.PARAGRAPH -> {
                Paragraph(markdownState, astNode)
            }
            MarkdownElementTypes.CODE_FENCE -> {
                CodeBlock(markdownState = markdownState, astNode = astNode)
            }
            MarkdownElementTypes.BLOCK_QUOTE -> {
                BlockQuote(markdownState = markdownState, astNode = astNode)
            }
            MarkdownElementTypes.UNORDERED_LIST -> {
                UnOrderedList(astNode = astNode, markdownState = markdownState)
            }
            MarkdownElementTypes.ORDERED_LIST -> {
                OrderedList(astNode = astNode, markdownState = markdownState)
            }
            MarkdownTokenTypes.HORIZONTAL_RULE -> {
                Divider()
            }
            GFMElementTypes.TABLE -> {
                MarkdownTable(markdownState = markdownState, astNode = astNode)
            }
        }
//        Column {
//            astNode.children.forEach {
//                Text(text = it.type.toString())
//            }
//        }
    }
}